package com.dxysun.gateway.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;

/**
 * @author dongxiyan
 * @date 2019/11/17 13:58
 */

//@Configuration
public class RouteConfig
{

//	@Bean
	public RouteLocator customRouteLocator(RouteLocatorBuilder builder)
	{
		return builder.routes()
				.route("path_dxy",
				r -> r.path("/2019/10/27/javaForKafka3/").uri("https://dxysun.com").filter((e, c) -> {
					System.out.println("path_dxy filter");
					System.out.println(e.getRequest().getURI().toString());
					System.out.println("response:" + e.getResponse().getStatusCode());
					return c.filter(e);
				}))
				.route("path_dxy_me", r -> r.path("/me").uri("https://dxysun.com").filter((e, c) -> {
					System.out.println("path_dxy_me filter");
					System.out.println(e.getRequest().getURI().toString());
					System.out.println("response:" + e.getResponse().getStatusCode());
					return c.filter(e);
				}))
				.route("blog", r -> r.path("/dxy1065").uri("https://blog.csdn.net"))
//				.route("data", r -> r.path("/data").uri("http://localhost:8010/test/"))
//				.route("hello", r -> r.path("hello").uri("http://localhost:8010"))
//				.route("index", r -> r.query("name").uri("http://localhost:8010"))
				.build();
	}

}
